<?php
$fieldSet =Database::$orderFieldSet;
$fieldSet['Verpacker'] = 'packer';


?>

<h1>Verkaufvertrag anlegen</h1>
<div class="addFormContainer" id="addOrder">
    <form action="./index.php?fnc=order&orderId=<?php echo $this->getTplVar('nextOrderId'); ?>" method="post">
        <?php
        foreach($fieldSet AS $key =>$val){
            if($val =='factor'){
                echo '<label>'.$key.':</label><input type="text"  value="1.1" name="'.$val.'" /><br />';
            }else{
                echo '<label>'.$key.':</label><input type="text" name="'.$val.'" value="'.$this->getTplVar($val).'" /><br />';
            }
        }
        ?>

        <br />
        <br />
        <input type="hidden" name="action" value="add" />
        <label></label><input value="Anlegen" type="submit" />
    </form>
</div>
<?php
echo $this->getTplVar('msg');

$addition = array('Erstellungsdatum'=>'create_time','Zustand'=>'order_status','Abgesendetsdatum'=>'out_time','Preis(Euro)'=>'price_e','Preis(Yuan)'=>'price_y', 'verpacker'=>'packer');
$titles = array("&nbsp;");
$titles = array_merge($titles, array_keys($addition));
$titles = array_merge($titles, array_keys($fieldSet));
$itemList = array_values(Database::$orderFieldSet);
$itemList = array_merge($addition, $itemList);

$newItemList = array_merge($addition, Database::$orderFieldSet);


?>
<h1>Verträge List</h1>
<div class="editFormContainer" id="editOrder">
    <form action="./index.php?fnc=order" method="post">

        <?php
        $length1 = 5;
        $length2 = 10;
        $length3 = 15;
        $length4 = 20;
        ?>

        <!--table class="orderList">
            <tbody>
            <tr>
               <?php
               //var_dump($titles);
               foreach($titles AS $title){
                   echo Helper::renderTableTitle($length1, $title);
               }
               ?>
            </tr>
            <?php
            $list = $this->getTplVar('list');
            //var_dump($list);
            if (is_array($list) && count($list) > 0){

                foreach ($list AS $order){
                    $link = './index.php?fnc=order&orderId='.$order['id'];

                    echo '<tr>';
                    //check box <label for="'.$article['id'].'" class="selectBoxLabel">'.$article['name_de'].'</label></b>
                    echo '<td width="'.$length1.'%" valign="top"><div class="column"><input type="checkbox" name="orderId[]" class="selectBox"  value="'.$order['id'].'" id="'.$order['id'].'"></div></td>';

                    $createTime = null;
                    foreach($itemList AS $item){
                        if ($item == 'create_time'){
                            $createTime = $order[$item];
                            echo Helper::renderTdItem($length1, $order[$item],$link);
                        }else{
                            if ($item ==  'out_time' && $order[$item] == $createTime ){
                                $order[$item] = '-----';
                            }

                            echo Helper::renderTdItem($length1, $order[$item]);
                        }

                    }

                    echo '</tr>';
                }
            }

            ?>
            </tbody>
        </table--->

        <?php
        $list = $this->getTplVar('list');
        //var_dump($list);
        if (is_array($list) && count($list) > 0){

            foreach ($list AS $order){
                $link = './index.php?fnc=order&orderId='.$order['id'];
                $table = '<table class="contacts" cellspacing="0" summary="Contacts template">';
                $table .= '<tr>';
                $table .= '<td class="contactDept" colspan="3"><div class="column"><input type="checkbox" name="orderId[]" class="selectBox"  value="'.$order['id'].'" id="'.$order['id'].'"></div><label></label><div class="column"><a href="'.$link.'">Order-Nr: '.$order['order_code'].'</a></div></td>';
                $table .= '</tr>';
                unset($newItemList['Order-Nr']);
                foreach ($newItemList AS $key => $val){
                    if ($val == 'create_time'){
                        $createTime = $order[$val];

                    }else{
                        if ($val ==  'out_time' && $order[$val] == $createTime ){
                            $order[$val] = '-----';
                        }
                    }

                    $table .= Helper::renderTableItem($key, $order[$val]);
                }

                $table .= '</table>';
                echo $table;
            }
        }

        ?>

        <input type="submit" name="action" value="Löschen"/>
        <!--input type="submit" name="action" value="Packen" /-->
        <input type="submit" name="action" value="Abgesendet" />
        <!---

        <table cellpadding="0" cellspacing="0" class="btm-blk"><tbody><tr><td width="25px;"><input type="checkbox" value="BulkCheckAction" name="BkCkBm" id="BkCkBm240"><label class="g-hdn" for="BkCkBm240">Alle markieren</label></td><td><div class="BottomBulk"><b id="v4-My_38_24" class="bn-w bn-m bn-pad trsb-S"><i>Notiz hinzufügen</i><span id="spn_v4-My_38_24" class="bn-b trsb-b trsb-S"><input id="but_v4-My_38_24" name="BulkAddNote" value="Notiz hinzufügen" title="" type="button"><b id="txt_v4-My_38_24">Notiz hinzufügen</b></span></b><b id="v4-My_38_25" class="bn-w bn-m bn-pad trsb-S"><i>Löschen</i><span id="spn_v4-My_38_25" class="bn-b trsb-b trsb-S"><input id="but_v4-My_38_25" name="SubmitAction.BulkDelete" value="Löschen" title="" type="button"><b id="txt_v4-My_38_25">Löschen</b></span></b><b id="v4-My_38_26" class="bn-w bn-m bn-pad trsb-S"><i>Vergleichen</i><span id="spn_v4-My_38_26" class="bn-b trsb-b trsb-S"><input id="but_v4-My_38_26" name="SubmitAction.BulkCompare" value="Vergleichen" title="" type="submit"><b id="txt_v4-My_38_26">Vergleichen</b></span></b><input type="hidden" name="coaction" value="compare"><b id="v4-My_38_27" class="bn-w bn-m bn-pad trsb-S"><i>Auf die Liste</i><span id="spn_v4-My_38_27" class="bn-b trsb-b trsb-S"><input id="but_v4-My_38_27" name="Artikel zu Liste(n) hinzufügen" value="Auf die Liste" title="" type="button"><b id="txt_v4-My_38_27">Auf die Liste</b></span></b></div></td></tr></tbody></table>

         --->
    </form>

</div>